/*!
\copyright  Copyright (c) 2023 Qualcomm Technologies International, Ltd.\n
            All Rights Reserved.\n
            Qualcomm Technologies International, Ltd. Confidential and Proprietary.
\file       avrcp_profile_event.h
\brief      LE Audio Broadcast Periodic Advertising Events
*/

#ifndef LE_AUDIO_PERIODIC_ADVERTISING_CHANNEL_EVENT_SPEC_H_
#define LE_AUDIO_PERIODIC_ADVERTISING_CHANNEL_EVENT_SPEC_H_

#include "channel_event_spec_ids.h"
/*! @{ */

/*! \brief The LE Audio Periodic Advertising event channel */
#define EVENT_BUS_CHANNEL_LE_AUDIO_PERIODIC_ADVERTISING     le_audio_periodic_advertising_event_channel

/*! \brief The LE Audio Periodic Advertising events */
typedef enum
{
    le_audio_periodic_advertising_sync_established,
    le_audio_periodic_advertising_report_recieved,
    le_audio_periodic_advertising_sync_transfer_recieved,
    le_audio_periodic_advertising_sync_lost,
    le_audio_periodic_advertising_scan_timeout,
} le_audio_periodic_advertising_event_t;
 
typedef struct
{
    uint16 status;
    uint16 sync_handle;
    /*! The Advertising SID used to identify an advertising set from many
        advertising sets on a device.
        0x00 - 0x0F */
    uint8 adv_sid;
    /*! Bluetooth address of advertiser.
        0xYYXXXXXXXXXXXXXX
        YY = Public Device Address, Random Device Address, Public Identity Address, etc..
        XX = 6 octet address */
    typed_bdaddr taddr;
    /*! The secondary phy the advert was received on.
        1 - LE 1M
        2 - LE 2M
        3 - LE Coded */
    uint8 adv_phy;
    /*! Interval of the periodic advertising.
        N = 0x6 to 0xFFFF  (Time = N * 1.25 ms)
        0 = No periodic advertising */
    uint16 periodic_adv_interval;
    /*! 0x00 = 500 ppm
        0x01 = 250 ppm
        0x02 = 150 ppm
        0x03 = 100 ppm
        0x04 = 75 ppm
        0x05 = 50 ppm
        0x06 = 30 ppm
        0x07 = 20 ppm */
    uint8 adv_clock_accuracy;
}  le_audio_periodic_advertising_sync_established_t;

typedef struct
{
    uint16 sync_handle;
    uint16 adv_data_len;
    uint8 tx_power;
    uint8 rssi;
    uint8 cte_type;
    uint8 dummy;
    /* Needs to be aligned 32-bit boundary before data member */
    uint8 adv_data[1];
}  le_audio_periodic_advertising_report_recieved_t;

typedef struct
{
    /*! A status value indicating if the local Controller has synchronized to a
    periodic advertising stream after receiving sync info from a connected
    peer. */
    uint8 status;
    /*! Value of the adverting SID subfield in the ADI field of the PDU. */
    uint8 adv_sid;
    /*! A handle to identify the periodic adverting train that the Controller
        has synchronized to. */
    uint16 sync_handle;
    /*!  */
    uint16 service_data;
    /*! The Bluetooth address of the advertiser transmitting the periodic train
        that has been synchronized to. */
    typed_bdaddr adv_addr;
}  le_audio_periodic_advertising_sync_transfer_recieved_t;

typedef struct
{
    uint16 sync_handle;
} le_audio_periodic_advertising_sync_lost_t;

/*! @} */

#endif /* LE_AUDIO_PERIODIC_ADVERTISING_CHANNEL_EVENT_SPEC_H_ */
